package com.mkh.st.common.utils.threadpool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 自定义拒绝策略，拒绝任务只打印日志
 *
 * @Author yhj
 * @Date 2020/12/2
 **/
@Slf4j
public class LogRejectedPolicy implements RejectedExecutionHandler {

	public LogRejectedPolicy() {
	}

	@Override
	public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
		log.error("Task {} rejected from {}", r.toString(), executor.toString());
	}
}
